package com.turbo.config;

import com.intellij.ide.FileIconProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFileSystemItem;
import com.intellij.psi.util.PsiUtilCore;
import icons.PluginIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
 * 指定文件的icon 并在plugin.xml中注册
 * 将demo.yaml 或者 demo.yml 指定图标
 */
public class DemoFileIconProvider implements FileIconProvider {
    @Override
    public @Nullable
    Icon getIcon(@NotNull VirtualFile file, int flags, @Nullable Project project) {
        PsiFileSystemItem psiFile = PsiUtilCore.findFileSystemItem(project, file);
        if (psiFile != null && ("demo.yaml".equals(psiFile.getName()) || "demo.yml".equals(psiFile.getName()))) {
            return PluginIcons.DEMO_ACTION;
        } else {
            return null;
        }
    }
}
